<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="spring" 	uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="tiles" 	uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c"		uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" 	uri="http://www.springframework.org/tags/form" %>

<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" pageEncoding="utf-8"%>

<script type="text/javascript">
$(document).ready(function(){
    
	var gridPersonsList = $("#gridCompaniesList");
	
	gridPersonsList.kendoGrid({
	    	dataSource : {
	            type     : "json",
	            transport: {
	                read: "json/listRegCompanies"
	            },
	            schema   : {
	                data: ""
	            }
	        },
	        columns: [
	  				{
	  					field:"id",  							
	  					title: "#",
	  					width: 40,
	  					hidden: true
	  				},
	            		{	
	  					field:"idno",  						
	  					title: "Cod fiscal",
	  					sortable: true,
	  					width: 100 , 
	  					template: renderIdno
	  				},
	  				 {field: "companyName", 					title: "Denumire firmă", 					width: 100},
	  				 {field: "refActivityType", 				title: "Genul de activitate", 				width: 120, template: renderActivityType},
	                 {field: "phoneMob", 					title: "Telefon mobil", 				width: 90},
	                 {field: "emal", 						title: "E-mail", 				width: 120},
	                 {field: "skype", 						title: "Skype", 				width: 120},
	                 {field: "bossNameSurname", 				title: "Director", 				width: 120}
	            ],
	          width : 750,
	          sortable: true,
	          refresh: true, 
	          pageable: {
	        	  pageSize: 15,
	        	  pageSizes: [10,15,20],
	        	  refresh: true 
	          }
	    });    
	 
		function  renderIdno (dataItem) {
			var result = "<a href='#' onclick=\"submitPJPopup (" +  dataItem.id + " )\"  >" + kendo.htmlEncode(dataItem.idno) + "</a>";
			//console.log(result);
			return result; 
		};   

		function  renderActivityType(dataItem) {
			var result  = "";
			if (dataItem.refActivityType) {
				result = dataItem.refActivityType.mdValue;
			}
			return result; 
		};    
});

function  submitPJPopup (id) {
	console.log (id);
	
	var returnEn = $("#returnEntity").val();
 	if (returnEn == "ANCHETA") {
 		parent.getRegCompanysApp (id);	
 	} 
 	
 	if (returnEn == "CONTRACT") {
 		parent.getRegCompanysContr(id);	
 	}
 	
	$("#windowClientiPJListPopup").data("kendoWindow").close();
	
};


</script>
<input id="returnEntity" type="hidden" value="${returnEntity}"/> 
<div id="gridCompaniesList"></div>




